import axios from "axios";

const baseURLObj = {
    'development':'/api',
    'production':'http://47.94.148.165:3001/api'
}

const instance = axios.create({
    baseURL:baseURLObj[process.env.NODE_ENV],
    timeout:10000
})

instance.interceptors.request.use(config=>{
    let token = localStorage.getItem("token");
     if(token){
         config.headers.token=token;
     }
     return config;
 },(err)=>{
   return  Promise.reject(err)
 })
 
 instance.interceptors.response.use(res=>{
     return res;
 },(err)=>{
     return Promise.reject(err)
 })
 
 export default instance